package com.lotusfall.service;

import com.github.pagehelper.PageInfo;
import com.lotusfall.api.ApiUserService;
import com.lotusfall.pojo.User;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserService {
    @DubboReference(version ="1.0")
    private ApiUserService apiUserService;

    /**
     * 查询所有用户
     * @return
     */
    public List<User> queryAll() {
        return this.apiUserService.queryAll();
    }


    /**
     * 通过用户名查询用户
     * @param username
     * @return
     */
    public User selectUserByUsername(String username) {
        return this.apiUserService.selectUserByUsername(username);
    }

    /**
     * 分页查询用户列表
     * @param page
     * @param pageSize
     * @return
     */
    public PageInfo<User> queryUserList(Integer page, Integer pageSize) {
        return this.apiUserService.queryUserList(page,pageSize);
    }

    /**
     * 新增用户
     * @param user
     * @return
     */
    public boolean addUser(User user){
        // 有时间可以写一下对用户名和密码合法性的判断
        return this.apiUserService.addUser(user);
    }

    public boolean setUserAvatar(String username,String url){
        return this.apiUserService.setUserAvatar(username,url);
    }

}
